<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org" xmlns:cb="http://www.ossbar.com/">
<head th:include="layout/head" />
<!-- 加载js -->
<div th:include="layout/foot" />
<script type="text/javascript">
	cb.loadmodules(["validate","ajax","lay","jqgrid"]);
</script>
<body>
<div class="panel-body">
		<div id="query_area">
			<!-- 查询条件区域begin-->
			<table class="table table-bordered FormView cb-table-fun" border="0"
				cellspacing="1" cellpadding="0">
				
				<tr>
					<td class="cb-label">邮箱账号</td>
					<td class="cb-value"><input type="text" id="maAccount" name="maAccount"
						class="form-control cb-form-control"></td>
					<td class="cb-label">邮箱显示名称</td>
					<td class="cb-value"><input type="text" id="maShowname" name="maShowname"
						class="form-control cb-form-control"></td>
				</tr>
			</table>
		</div>
		<!-- 查询条件区域end-->
		<!-- 按钮栏布局begin -->
		<div id="toolbar_area" class="toolbar_area">
			<a class="btn btn-default cb-btn" lay-filter="formDemo"
				href="javascript:void(0)" onclick="query()"><i
				class="glyphicon glyphicon-search"></i>&nbsp;查询</a> <a
				lay-filter="hasPermission('mail:tmailaccount:add')" class="btn btn-default cb-btn"
				onclick="add()"><i class="glyphicon glyphicon-plus"></i>&nbsp;新增</a>
			<a lay-filter="hasPermission('mail:tmailaccount:edit')" class="btn btn-default cb-btn"
				onclick="edit()"><i class="glyphicon glyphicon-edit"></i>&nbsp;修改</a>
			<a lay-filter="hasPermission('mail:tmailaccount:remove')" class="btn btn-default cb-btn"
				onclick="del()"><i class="glyphicon glyphicon-trash"></i>&nbsp;删除</a>
		</div>
		<!-- 按钮栏布局end -->
		</form>
	</div>
	<table id="jqGrid"></table>
	<div id="jqGridPager"></div>
</body>
<script type="text/javascript">
	$(function() {
		$("#jqGrid").jqGrid({
			url : cb.baseurl + 'mail/tmailaccount/query',
			datatype : "json",
			colModel : [ 
				{
				label:'账户Id',
				name : 'maId',
				width : 100,
				key : true,
				hidden:true
				}, 
				{
				label:'邮箱账号',
				name : 'maAccount',
				width : 200
				},
				{
				label:'邮箱显示名称',
				name : 'maShowname',
				width : 100
				},
				{
				label:'收取邮件频率',
				name : 'maMinute',
				width : 100
				},
				{
				label:'邮箱类型',
				name : 'maProtocol',
				width : 100
				},
				{
				label:'收件服务器',
				name : 'maReceServer',
				width : 180
				},
				{
				label:'收件服务器端口',
				name : 'maRsPort',
				width : 100
				},
				{
				label:'发件服务器',
				name : 'maSendServer',
				width : 180
				},
				{
				label:'发件服务器端口',
				name : 'maSsPort',
				width : 100
				},
				{
				label:'是否主账户',
				name : 'maIsMain',
				width : 100
				},
				{
				label:'创建时间',
				name : 'createTime',
				width : 100
				}
				 ],
			viewrecords : true,
			height : 385,
			rowNum : 10,
			rowList : [ 10, 30, 50 ],
			rownumbers : true,
			rownumWidth : 25,
			autowidth : true,
			multiselect : true,
			pager : "#jqGridPager",
			jsonReader : {
				root : "page.list",
				page : "page.currPage",
				total : "page.totalPage",
				records : "page.totalCount"
			},
			prmNames : {
				page : "page",
				rows : "limit",
				order : "order"
			},
			gridComplete : function() {
				//隐藏grid底部滚动条
				$("#jqGrid").closest(".ui-jqgrid-bdiv").css({
					"overflow-x" : "hidden"
				});
			}
		});

	});

	//查询
	function query() {
		var page = $("#jqGrid").jqGrid('getGridParam', 'page');
		$("#jqGrid").jqGrid('setGridParam', {
			postData : {
		"maId" : $("#maId").val()
		,	
		"maAccount" : $("#maAccount").val()
		,	
		"maPasswd" : $("#maPasswd").val()
		,	
		"maToken" : $("#maToken").val()
		,	
		"maSign" : $("#maSign").val()
		,	
		"maSignState" : $("#maSignState").val()
		,	
		"maShowname" : $("#maShowname").val()
		,	
		"maMinute" : $("#maMinute").val()
		,	
		"maProtocol" : $("#maProtocol").val()
		,	
		"maReceServer" : $("#maReceServer").val()
		,	
		"maRsPort" : $("#maRsPort").val()
		,	
		"maRsIsssl" : $("#maRsIsssl").val()
		,	
		"maSendServer" : $("#maSendServer").val()
		,	
		"maSsIsssl" : $("#maSsIsssl").val()
		,	
		"maSsPort" : $("#maSsPort").val()
		,	
		"maBackType" : $("#maBackType").val()
		,	
		"maIsMain" : $("#maIsMain").val()
		,	
		"maCustom" : $("#maCustom").val()
		,	
		"orgId" : $("#orgId").val()
		,	
		"createUserId" : $("#createUserId").val()
		,	
		"createTime" : $("#createTime").val()
		,	
		"updateUserId" : $("#updateUserId").val()
		,	
		"updateTime" : $("#updateTime").val()
			
			},
			page : page
		}).trigger("reloadGrid");
	}
	//新增
	function add() {
		cb.winopen('新增', '1000px', '600px', 'mail/tmailaccount/add', 'yes',
				function() {
					query()
				});
	}
	//修改
	function edit() {
		var id = cb.getselectedrow("#jqGrid")
		if (id)
			cb.winopen('修改', '1000px', '600px', 'mail/tmailaccount/edit?id=' + id,
					'yes', function() {
						query()
					});
	}
	//删除
	function del(){
		var ids = cb.getselectedrows("#jqGrid");
		if(ids){
			cb.confirm("删除邮箱账户会同步删除该账户下面的所有邮件，确定删除吗？",function(){
				cb.post("mail/tmailaccount/remove",JSON.stringify(ids),function(result){
					cb.alert("删除成功",function(){query();});
					
				},{contentType:"application/json"});
				
			})
		}
	}
</script>
</html>